package org.sql.statement.operation;

import org.sql.statement.builder.AbstractStatementBuilder;
import org.sql.statement.builder.Constants;
import org.sql.statement.builder.StatementBuilder;
import org.sql.statement.builder.StatementBuilder.StatementType;
import org.sql.statement.operation.intf.Operation;

public class SelectOperation extends AbstractStatementBuilder implements
		Operation {

	private static final String STATEMENT_TYPE = StatementType.SELECT
			.toString();

	public String buildStatement(StatementBuilder builder) {
		final StringBuilder sb = new StringBuilder();

		sb.append(STATEMENT_TYPE).append(Constants.CHAR_SPACE);
		sb.append(
				buildColumnsFragment(builder.isSelectAsterisk(),
						builder.getColumns())).append(Constants.CHAR_SPACE);
		sb.append(buildFromFragment(builder.getTables()));

		return sb.toString();
	}
}
